package com.ml.mall.mapper.coupon;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ml.mall.bean.res.coupon.CouponSupplierRes;
import com.ml.mall.entity.company.SysCompany;
import com.ml.mall.entity.coupon.SysCouponSupplierRelation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SysCouponSupplierRelationMapper extends BaseMapper<SysCouponSupplierRelation> {
    /**
     * @description    :通过优惠券id删除相关联的卖家
     * @author         :zxm
     * @date           :2021/5/21
    **/
    @Delete("delete from sys_coupon_supplier_relation where coupon_code = #{couponCode}")
    int deleteByCouponCode(@Param("couponCode") String couponCode);

    /**
     * @description    :通过优惠券id查询相关联的卖家
     * @author         :zxm
     * @date           :2021/5/21
    **/
    List<CouponSupplierRes> selectSupplierByCouponCode(@Param("couponCode") String couponCode);

    /**
     * @description    :查询卖家的某产品能否使用某优惠券
     * @author         :zxm
     * @date           :2021/5/28
     **/
    Long countSupplierUnUsableCoupon(@Param("couponCode") String couponCode, @Param("variantId") Long variantId);


    /**连表查询通过商家查询商家信息；*/
    List<SysCompany> selectCompanyInfoByCoupponCode(@Param("couponCode") String couponCode);
}